<template>
  <div class="container">
    <ul ref="pannel" class="goods-list-top" v-if="goods.length">
      <li v-for="item in goods" :key="item.id">
        <RouterLink to="/">
          <img  v-ilazy="item.picture"  :src='load' alt="" />
          <!-- 商品列表 -->
          <p class="name">{{ item.title || item.name }}</p>
          <p :class="{ desc: item.alt, price: item.price }">
            <span v-if="item.price">￥</span>{{ item.alt || item.price }}
          </p>
        </RouterLink>
      </li>
    </ul>

    <!-- 数据没显示出来就显示骨架屏 -->
    <ul class="goods-list-top" v-else>
      <li v-for="item in 4" :key="item">
        <p><XtxSkeleton width="306" height="306" bg="#eee" /></p>
        <p><XtxSkeleton width="306" height="32" bg="#eee" /></p>
        <p><XtxSkeleton width="306" height="32" bg="#eee" /></p>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'HomeList',
  props: {
    goods: {
      type: Array,
      default: () => []
    }
  },
  setup () {}
}
</script>

<style scoped lang="less">
.goods-list-top {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    // 激活效果
    transition: all 0.5s;
    &:hover {
      transform: translate3d(0, -6px, 0);
      box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
    }
    // end
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
    .desc {
      color: #999;
      font-size: 18px;
    }
    .price {
      color: @priceColor;
    }
  }
}
</style>
